/*                                  ATELIER                                   */

/* %%LICENSE_TAG%%                                                            */
package edu.gmu.view.cube;

import edu.gmu.atelier.AffineVector;
import edu.gmu.atelier.Vector;

/**
 * A Polygon represents a 2-D face in space with 4 vertices.
 *
 * @author  James H. Pope
 * @version $Revision:$ $Date:$
 */
public class Polygon
{
    // Index of specified coorinate
    protected AffineVector lowerLeft  = new AffineVector(0,0,0);
    protected AffineVector upperLeft  = new AffineVector(0,0,0);
    protected AffineVector upperRight = new AffineVector(0,0,0);
    protected AffineVector lowerRight = new AffineVector(0,0,0);
    

    /**
     * Creates a new Polygon with zero values (point at origin)
     */
    public Polygon( )
    {

    }

    /**
     * Creates a new Polygon (Rectangle) with specified values
     * @param x
     * @param y
     * @param width
     * @param height
     */
    public Polygon( double x, double y, double width, double height )
    {
        this.lowerLeft  = new AffineVector( x      ,        y );
        this.upperLeft  = new AffineVector( x      , y+height );
        this.upperRight = new AffineVector( x+width, y+height );
        this.lowerRight = new AffineVector( x+width,        y );
    }

    /**
     * Creates a new Polygon (Rectangle) with specified values
     * @param x
     * @param y
     * @param z
     * @param width
     * @param height
     */
    public Polygon( double x, double y, double z, double width, double height )
    {
        this.lowerLeft  = new AffineVector( x      ,        y, z );
        this.upperLeft  = new AffineVector( x      , y+height, z );
        this.upperRight = new AffineVector( x+width, y+height, z );
        this.lowerRight = new AffineVector( x+width,        y, z );
    }

    /**
     * Creates a new Polygon with specified values
     * @param lowerLeft
     * @param upperLeft
     * @param upperRight
     * @param lowerRight
     */
    public Polygon( AffineVector lowerLeft, AffineVector upperLeft,
                    AffineVector upperRight, AffineVector lowerRight )
    {
        this.lowerLeft  = lowerLeft;
        this.upperLeft  = upperLeft;
        this.upperRight = upperRight;
        this.lowerRight = lowerRight;
    }

    /**
     * Gets x
     * @return
     */
    public double getX()
    {
        return this.lowerLeft.getElement(Pen.X).doubleValue();
    }

    /**
     * Gets y
     * @return
     */
    public double getY()
    {
        return this.lowerLeft.getElement(Pen.Y).doubleValue();
    }

    /**
     * Gets width
     * @return
     */
    public double getWidth()
    {
        return this.upperRight.getElement(Pen.X).doubleValue()
             - this.lowerLeft.getElement(Pen.X).doubleValue();
    }

    /**
     * Gets height
     * @return
     */
    public double getHeight()
    {
        return this.upperRight.getElement(Pen.Y).doubleValue()
                - this.lowerLeft.getElement(Pen.Y).doubleValue();
    }

}

/*                                  ATELIER                                   */